%{
/* $Header: scan.l,v 2.2 01/10/02 10:27:02 przybyls Exp $ */
/*
   file: scan.l

     This lex(1) input file defines the tokens recognized by the IQ
     message compiler.

   author: John DeGood, May 92
*/
#include "cm.h"
#include <stdlib.h>
#include <string.h>
#include "y.tab.h"
%}
%%
\"[^"]*		{  /* string */
			/* if double quote at end is escaped keep scanning */
			if (yytext[yyleng - 1] == '\\')
				yymore();
			else
			{
				/* allocate space to return string */
				if ((yylval.str = (char *) calloc(yyleng, 1)) == NULL)
				{
					yyerror("calloc failed!");
					exit(1);
				}

				/* copy string, discarding leading '"' */
				strcpy(yylval.str, (char *) &yytext[1]);

				/* consume and discard trailing '"' */
				input();


				return(STRING);
			}
		}
#.*\n		{  /* comment */
		}

\/\*.*\*\/      {  /* c style comment */
                }

[a-zA-Z0-9_]*		{  /* keyword */

			/* strncpy relies on calloc to init mem to 0 */
			if ((yylval.str = (char *) calloc(yyleng+1, 1)) == NULL)
			{
				yyerror("calloc failed!");
				exit(1);
			}

			strncpy(yylval.str, (char *) &yytext[0], yyleng );

			return(WORD);
		}

\[ET\]          { return ( ET ); }      /* define an exception type */
\[ST\]          { return ( ST ); }      /* define an Setpoint type */
\[CT\]          { return ( CT ); }      /* define an conversion type */
\[MSG\]         { return ( MSG ); }     /* rename an exception message (don't use a default) */
\[RPT\]         { return ( RPT ); }     /* excpetion is repeatable, multiple occourences between clear */
\[GLP\]         { return ( GLP ); }     /* glp logging parameters for the exception */
\[CLASS\]       { return ( CLASS ); }   /* define a handler level for the exception type */
\[SMSG\]        { return ( STATUS_MSG ); }  /* define a message number for the status monitor */
\[CONV\]        { return ( CONV_CODE ); }  /* define a conversion routines to be used displaying parameter */
\[SC\]          { return ( SETPT_CLASS ); }  /* define a type of setpt, eg. oven setpt */
\[SN\]          { return ( SETPT_NAME ); }  /* define the type of setpt, eg. oven setpt */
\<eol\>         { return ( EOL ); }


[ \t]		{  /* white space */
		}
\n		{  /* newline */
		}
.		{  /* return anything else */
			return(yytext[0]);
		}
%%

/* user functions */
